home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Devices / SCSI Simple Sample / Src / AsyncSCSIPresent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  1.1 KB  |  59 lines  |  [TEXT/KAHL]

  1. /*                                AsyncSCSIPresent.c                                */
  2. /*
  3.  * AsyncSCSIPresent.c
  4.  * Copyright © 1992-94 Apple Computer Inc. All Rights Reserved.
  5.  */
  6. #include <OSUtils.h>
  7. #include <Traps.h>
  8. #ifndef _SCSIAtomic
  9. /*
  10.  * This is needed if you don't have Universal Headers.
  11.  */
  12. #define _SCSIAtomic    0xA089
  13. #endif
  14.  
  15. Boolean                        AsyncSCSIPresent(void);
  16. static Boolean                TrapAvailable(
  17.         short                    theTrap
  18.     );
  19.  
  20. Boolean
  21. AsyncSCSIPresent(void)
  22. {
  23.         return (TrapAvailable(_SCSIAtomic));
  24. }
  25.  
  26. /*
  27.  * TrapAvailable (see Inside Mac VI 3-8)
  28.  */
  29. #define NumToolboxTraps() (                                \
  30.         (NGetTrapAddress(_InitGraf, ToolTrap)            \
  31.                 == NGetTrapAddress(0xAA6E, ToolTrap))    \
  32.             ? 0x200 : 0x400                                \
  33.     )
  34. #define GetTrapType(theTrap) (                            \
  35.         ((theTrap) & 0x800 != 0) ? ToolTrap : OSTrap    \
  36.     )
  37.  
  38. static Boolean
  39. TrapAvailable(
  40.         short                    theTrap
  41.     )
  42. {
  43.         TrapType                trapType;
  44.         
  45.         trapType = GetTrapType(theTrap);
  46.         if (trapType == ToolTrap) {
  47.             theTrap &= 0x07FF;
  48.             if (theTrap >= NumToolboxTraps())
  49.                 theTrap = _Unimplemented;
  50.         }
  51.         return (
  52.             NGetTrapAddress(theTrap, trapType)
  53.             != NGetTrapAddress(_Unimplemented, ToolTrap)
  54.         );
  55. }
  56.  
  57.  
  58.  
  59.